﻿<template>
  <a-modal
    title="编辑查询费用列表"
    :width="900"
    :visible="visible"
    :confirmLoading="confirmLoading"
    @ok="handleSubmit"
    @cancel="handleCancel">
    <a-spin :spinning="confirmLoading">
      <a-form :form="form">
        <a-form-item label="HIS 系统跟踪号(唯一) " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入HIS 系统跟踪号(唯一) " v-decorator="['orgTraceNo']" />
        </a-form-item>
        <a-form-item label="就诊凭证类型固定为 02 身份证 " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入就诊凭证类型固定为 02 身份证 " v-decorator="['mdtrtCertType']" />
        </a-form-item>
        <a-form-item label="就诊凭证编号 " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入就诊凭证编号 " v-decorator="['mdtrtCertNo']" />
        </a-form-item>
        <a-form-item label="证件号 " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入证件号 " v-decorator="['certNo']" />
        </a-form-item>
        <a-form-item label="患者院内证件号 " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入患者院内证件号 " v-decorator="['hisCustId']" />
        </a-form-item>
        <a-form-item label="患者院内证件类 " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入患者院内证件类 " v-decorator="['hisCustType']" />
        </a-form-item>
        <a-form-item label="机构编号(国标医院编码)机构的国家统一编码 " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入机构编号(国标医院编码)机构的国家统一编码 " v-decorator="['orgCode']" />
        </a-form-item>
        <a-form-item label="分院编号分机构编号，以用来区分分院或者基卫，如果为空则默认为本院该字典需由定点机构提供 " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入分院编号分机构编号，以用来区分分院或者基卫，如果为空则默认为本院该字典需由定点机构提供 " v-decorator="['subOrgCode']" />
        </a-form-item>
        <a-form-item label="账户类型:01:门诊账户02:住院账户参考账户类型字典 " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入账户类型:01:门诊账户02:住院账户参考账户类型字典 " v-decorator="['accountType']" />
        </a-form-item>
        <a-form-item label="查询开始日期可空,处方日期格式：yyyy-MM-dd " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入查询开始日期可空,处方日期格式：yyyy-MM-dd " v-decorator="['beginDate']" />
        </a-form-item>
        <a-form-item label="查询截止日期可空,处方日期格式：yyyy-MM-dd " :labelCol="labelCol" :wrapperCol="wrapperCol" has-feedback>
          <a-input placeholder="请输入查询截止日期可空,处方日期格式：yyyy-MM-dd " v-decorator="['endDate']" />
        </a-form-item>
        <a-form-item v-show="false"><a-input v-decorator="['iD']" /></a-form-item>
      </a-form>
    </a-spin>
  </a-modal>
</template>

<script>
  import {
    NitfOrg002aInputEdit
  } from '@/api/modular/main/NitfOrg002aInputManage'
  export default {
    data () {
      return {
        labelCol: {
          xs: { span: 24 },
          sm: { span: 5 }
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 15 }
        },
        visible: false,
        confirmLoading: false,
        form: this.$form.createForm(this)
      }
    },
    methods: {
      // 初始化方法
      edit (record) {
        this.visible = true
        setTimeout(() => {
          this.form.setFieldsValue(
            {
              iD: record.iD,
              orgTraceNo: record.orgTraceNo,
              mdtrtCertType: record.mdtrtCertType,
              mdtrtCertNo: record.mdtrtCertNo,
              certNo: record.certNo,
              hisCustId: record.hisCustId,
              hisCustType: record.hisCustType,
              orgCode: record.orgCode,
              subOrgCode: record.subOrgCode,
              accountType: record.accountType,
              beginDate: record.beginDate,
              endDate: record.endDate
            }
          )
        }, 100)
      },
      handleSubmit () {
        const { form: { validateFields } } = this
        this.confirmLoading = true
        validateFields((errors, values) => {
          if (!errors) {
            for (const key in values) {
              if (typeof (values[key]) === 'object') {
                values[key] = JSON.stringify(values[key])
              }
            }
            NitfOrg002aInputEdit(values).then((res) => {
              if (res.success) {
                this.$message.success('编辑成功')
                this.confirmLoading = false
                this.$emit('ok', values)
                this.handleCancel()
              } else {
                this.$message.error('编辑失败：' + JSON.stringify(res.message))
              }
            }).finally((res) => {
              this.confirmLoading = false
            })
          } else {
            this.confirmLoading = false
          }
        })
      },
      handleCancel () {
        this.form.resetFields()
        this.visible = false
      }
    }
  }
</script>
